package stringMVC.model;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import stringMVC.service.UserService;


import java.util.List;

@RequestMapping("/message")
@RestController
public class MessageWall {
    @Autowired
    private UserService userService;

    @RequestMapping("/publish")
    public boolean publish(MessageInfo messageInfo){
        if(!StringUtils.hasLength(messageInfo.getMessage()) ||
        !StringUtils.hasLength(messageInfo.getTo()) ||
        !StringUtils.hasLength(messageInfo.getFrom())){
            return false;
        }
        userService.insertUserInfo(messageInfo);
        return true;
    }
    @RequestMapping("/getList")
    public List<MessageInfo> getList(){
        return userService.getList();
    }
}
